package com.roc.service.impl;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.roc.dao.DaoException;
import com.roc.dao.INegotiationDao;
import com.roc.page.BaseSearchCondition;
import com.roc.pojo.Negotiation;
import com.roc.pojo.TblMchtInf;
import com.roc.service.INegotiationService;
import com.roc.service.ServiceException;
import com.roc.util.Constance;

/**
 * 代付流水ServiceImpl
 *
 */
@Service("negotiationService")
public class NegotiationServiceImpl implements INegotiationService {
	static Logger logger = Logger.getLogger(NegotiationServiceImpl.class);

	@Autowired
	private INegotiationDao negotiationDao;

	@Override
	@Transactional(propagation = Propagation.REQUIRED, readOnly = true)
	public List<Negotiation> queryByConditions(
			BaseSearchCondition searchCondition) throws ServiceException {
		// TODO Auto-generated method stub
		List<Object> searchRsList = new ArrayList<Object>();
		List<Negotiation> negotiationList = new ArrayList<Negotiation>();
		try {
			searchRsList = negotiationDao.queryByConditions(searchCondition);
			// dealWidth(estrnLogList, searchRsList);
			// *********************************************************************************************************************
			if (searchRsList != null && searchRsList.size() > 0) {
				Iterator iterator = searchRsList.iterator();
				while (iterator.hasNext()) {
					Object[] obj = (Object[]) iterator.next();
					Negotiation nego = new Negotiation();
					nego.setTransDt(Constance.Null2EmptyTrim(obj[0]));
					nego.setTransTm(Constance.Null2EmptyTrim(obj[1]));
					nego.setRespCd(Constance.Null2EmptyTrim(obj[2]));
					nego.setTranSeq(Constance.Null2EmptyTrim(obj[3]));
					nego.setMchntCd(Constance.Null2EmptyTrim(obj[4]));
					nego.setMchntNm(Constance.Null2EmptyTrim(obj[5]));
					nego.setPyeBankNm(Constance.Null2EmptyTrim(obj[6]));
					nego.setPyeAcctNo(Constance.Null2EmptyTrim(obj[7]));
					nego.setPyeAcctNm(Constance.Null2EmptyTrim(obj[8]));
					/*nego.setPriBankNm(Constance.Null2EmptyTrim(obj[9]));*/	
					/*nego.setPriAcctNo(Constance.Null2EmptyTrim(obj[9]));
					nego.setPriAcctNm(Constance.Null2EmptyTrim(obj[10]));*/
					nego.setTranAmt(Constance.Null2EmptyTrim(obj[11]));
					/*nego.setStlmFee(Integer.parseInt(obj[12].toString()));
					nego.setStlmAmt(Integer.parseInt(obj[13].toString()));*/
					negotiationList.add(nego);
					
					
				}
			}

		} catch (DaoException e) {
			logger.error(e.getMessage(), e);
			throw new ServiceException(e.getMessage(), e);
		}
		return negotiationList;
	}

}
